var pie_002 = echarts.init(document.getElementById('pie-002'));
pie_002.setOption({
    tooltip: {
        trigger: 'item',
        formatter(params){
            return params.name+ '<br/>'+params.seriesName+"："+params.value+' ('+params.percent+'%)'+'<br/>'+"项目金额："+params.data.budget;
        }
    },
    series: [{
        name: '项目数量',
        type: 'pie',
        radius: ['50%', '70%'],
        avoidLabelOverlap: false,
        label: {
            show: false,
            position: 'center'
        },
        emphasis: {
            label: {
                show: true,
                fontSize: '30',
                fontWeight: 'bold'
            }
        },
        labelLine: {
            show: false
        },
        data: []
    }]
});

commonPie();

function searchPie() {
    var sdate = $('#sdatePie').val();
    var edate = $('#edatePie').val();
    var param = {sdate:sdate, edate:edate}
    commonPie(param);
}

function commonPie(param = null){
    var date=new Date;
    var y = date.getFullYear()
    $('#sdatePie').val(y+'-01-01');

    $.get('./index.php?a=totalAgency&m=report|main&d=report', param).done(function (data) {
        data = JSON.parse(data)
        pie_002.setOption({
            series: [{
                data:data
            }]
        });
    });
}

pie_002.on('click', function (params) {
    let sdate = $('#sdatePie').val();
    let edate = $('#edatePie').val();
    console.log(sdate,edate);
    let urls = 'report,main,list,proxygov='+params.name+',sdate='+sdate+',edate='+edate;
    addtabs({num:'num329',url:urls,icons:'',name:'采购项目执行汇总'});
});
